package com.eci.example;

import com.eci.context.context.core.TheRepositoryFactoryBean;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableAsync;

@SpringCloudApplication
@EnableJpaRepositories(repositoryFactoryBeanClass = TheRepositoryFactoryBean.class)
@EntityScan(basePackageClasses = {ExampleClientApplication.class, Jsr310JpaConverters.class})
@EnableFeignClients(basePackages = "com.eci")
@EnableAsync
@ComponentScan(value = "com.eci")
public class ExampleClientApplication extends SpringBootServletInitializer {

    public static void main(String[] args) {
        // 如果用application.yml配置logback的配置文件和日志存放路径那么，必须修改启动类里的那个配置代码，反之使用bootstrap.yml不影响。
        // 原因： logback-spring.xml 启动时会被读取两遍， 因为 Spring Cloud 程序有两个上下文，用application.yml会产生冲突，使用bootstrap.yml则不会。
//        System.setProperty("spring.cloud.bootstrap.enabled", "false");
        SpringApplication.run(ExampleClientApplication.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(ExampleClientApplication.class);
    }
}
